package com.edu.api.common.web.base.http;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.ArrayList;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper = true)
public class PageResult<L extends List<T>, T> extends Result<L> {

	private long totalSize;
	private long totalPages;
	private long pageSize;
	private long pageNum;


	public PageResult(){

	}

	public PageResult(IPage<T> page) {
		this.setTotalSize(page.getTotal());
		this.setTotalPages(page.getPages());
		this.setPageSize(page.getSize());
		this.setPageNum(page.getCurrent());
		this.setData((L) page.getRecords());
	}

	public static void main(String[] args) {
		List<Integer> list = new ArrayList<>();
		list.add(1);
		list.add(2);
		list.add(3);
		list.add(4);
		PageResult<List<Integer>,Integer> pageResult=new PageResult<>();
		pageResult.setData(list);
		System.out.println(pageResult.getData());
	}

}